﻿#region Copyright © 2008-2009, DevExpressContrib (MIT License)
// This software is licensed under The MIT License:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#endregion

namespace Test.Xpo.UpdateSchema
{
    using System;
    using DevExpress.Xpo;
    using DevExpressContrib.Xpo.UpdateSchema.Interface;

    public class TestSchemaVersionStringInvalidProperties : SchemaVersionBase<string>
    {

        /// <summary>
        /// Increment the requiredSchemaVersion value for each version of the schema
        /// </summary>
        private string requiredSchemaVersion = "Hello World";


        public TestSchemaVersionStringInvalidProperties(IDataLayer dataLayer) : base(dataLayer) { }

        public TestSchemaVersionStringInvalidProperties() : base() { }


        public override string DateVersionUpdatedPropertyName { get { return "SchemaVersionUpdatedInvalid"; } }

        /// <summary>
        /// For testing allow the requiredSchemaVersion to be changed.
        /// </summary>
        public string RequiredSchemaVersionMutable
        {
            get { return requiredSchemaVersion; }
            set { requiredSchemaVersion = value; }
        }

        public override string VersionPropertyName { get { return "SchemaVersionInvalid"; } }

        public override Type XpoObjectType { get { return typeof(SchemaVersionXpoClassString); } }


        public override string GetRequiredSchemaVersion() { return requiredSchemaVersion; }
    }

    public class TestSchemaVersionStringInvalidXpoType : SchemaVersionBase<string>
    {

        /// <summary>
        /// Increment the requiredSchemaVersion value for each version of the schema
        /// </summary>
        private string requiredSchemaVersion = "Hello World";


        public TestSchemaVersionStringInvalidXpoType(IDataLayer dataLayer) : base(dataLayer) { }

        public TestSchemaVersionStringInvalidXpoType() : base() { }


        public override string DateVersionUpdatedPropertyName { get { return "SchemaVersionUpdated"; } }

        /// <summary>
        /// For testing allow the requiredSchemaVersion to be changed.
        /// </summary>
        public string RequiredSchemaVersionMutable
        {
            get { return requiredSchemaVersion; }
            set { requiredSchemaVersion = value; }
        }

        public override string VersionPropertyName { get { return "SchemaVersion"; } }

        public override Type XpoObjectType { get { return typeof(SchemaVersionXpoClassStringInvalidXpoType); } }


        public override string GetRequiredSchemaVersion() { return requiredSchemaVersion; }
    }

    public class SchemaVersionXpoClassStringInvalidXpoType
    {

        public SchemaVersionXpoClassStringInvalidXpoType(Session session) { }


        public string SchemaVersion { get; set; }
    }

    public class TestSchemaVersionString : SchemaVersionBase<string>
    {

        /// <summary>
        /// Increment the requiredSchemaVersion value for each version of the schema
        /// </summary>
        private string requiredSchemaVersion = "Hello World";


        public TestSchemaVersionString(IDataLayer dataLayer) : base(dataLayer) { }

        public TestSchemaVersionString() : base() { }


        public override string DateVersionUpdatedPropertyName { get { return "SchemaVersionUpdated"; } }

        /// <summary>
        /// For testing allow the requiredSchemaVersion to be changed.
        /// </summary>
        public string RequiredSchemaVersionMutable
        {
            get { return requiredSchemaVersion; }
            set { requiredSchemaVersion = value; }
        }

        public override string VersionPropertyName { get { return "SchemaVersion"; } }

        public override Type XpoObjectType { get { return typeof(SchemaVersionXpoClassString); } }


        public override string GetRequiredSchemaVersion() { return requiredSchemaVersion; }
    }

    public class SchemaVersionXpoClassString : XPObject
    {

        private string schemaVersion;
        private DateTime schemaVersionUpdated;


        public SchemaVersionXpoClassString(Session session) : base(session) { }


        public string SchemaVersion
        {
            get { return schemaVersion; }
            set { SetPropertyValue("SchemaVersion", ref schemaVersion, value); }
        }

        public DateTime SchemaVersionUpdated
        {
            get { return schemaVersionUpdated; }
            set { SetPropertyValue("SchemaVersionUpdated", ref schemaVersionUpdated, value); }
        }
    }

    public class TestSchemaVersionInt : SchemaVersionBase<int>
    {

        /// <summary>
        /// Increment the requiredSchemaVersion value for each version of the schema
        /// </summary>
        private int requiredSchemaVersion = 1;


        public TestSchemaVersionInt(IDataLayer dataLayer) : base(dataLayer) { }


        public override string DateVersionUpdatedPropertyName { get { return "SchemaVersionUpdated"; } }

        /// <summary>
        /// For testing allow the requiredSchemaVersion to be changed.
        /// </summary>
        public int RequiredSchemaVersionMutable
        {
            get { return requiredSchemaVersion; }
            set { requiredSchemaVersion = value; }
        }

        public override string VersionPropertyName { get { return "SchemaVersion"; } }

        public override Type XpoObjectType { get { return typeof(SchemaVersionXpoClassInt); } }


        public override int GetRequiredSchemaVersion() { return requiredSchemaVersion; }
    }

    public class SchemaVersionXpoClassInt : XPObject
    {

        private int schemaVersion;
        private DateTime schemaVersionUpdated;


        public SchemaVersionXpoClassInt(Session session) : base(session) { }


        public int SchemaVersion
        {
            get { return schemaVersion; }
            set { SetPropertyValue("SchemaVersion", ref schemaVersion, value); }
        }

        public DateTime SchemaVersionUpdated
        {
            get { return schemaVersionUpdated; }
            set { SetPropertyValue("SchemaVersionUpdated", ref schemaVersionUpdated, value); }
        }
    }

    public class TestSchemaVersionNoDateInt : SchemaVersionBase<int>
    {

        /// <summary>
        /// Increment the requiredSchemaVersion value for each version of the schema
        /// </summary>
        private int requiredSchemaVersion = 1;


        public TestSchemaVersionNoDateInt(IDataLayer dataLayer) : base(dataLayer) { }


        /// <summary>
        /// For testing allow the requiredSchemaVersion to be changed.
        /// </summary>
        public int RequiredSchemaVersionMutable
        {
            get { return requiredSchemaVersion; }
            set { requiredSchemaVersion = value; }
        }

        public override string VersionPropertyName { get { return "SchemaVersion"; } }

        public override Type XpoObjectType { get { return typeof(SchemaVersionXpoClassIntNoDate); } }


        public override int GetRequiredSchemaVersion() { return requiredSchemaVersion; }
    }

    public class SchemaVersionXpoClassIntNoDate : XPObject
    {

        private int schemaVersion;
        private DateTime schemaVersionUpdated;


        public SchemaVersionXpoClassIntNoDate(Session session) : base(session) { }


        public int SchemaVersion
        {
            get { return schemaVersion; }
            set { SetPropertyValue("SchemaVersion", ref schemaVersion, value); }
        }

        public DateTime SchemaVersionUpdated
        {
            get { return schemaVersionUpdated; }
            set { SetPropertyValue("SchemaVersionUpdated", ref schemaVersionUpdated, value); }
        }
    }
}